package practice3;

import org.junit.Test;
import static org.junit.Assert.*;

public class ArithmeticTest {
    @Test
    public void testAddition() {
        Arithmetic arith = new Arithmetic(3, 5, '+');
        assertEquals(8, arith.getResult());
        assertEquals("3 + 5 = 8", arith.toString());
    }

    @Test
    public void testSubtraction() {
        Arithmetic arith = new Arithmetic(10, 4, '-');
        assertEquals(6, arith.getResult());
        assertEquals("10 - 4 = 6", arith.toString());
    }

    @Test(expected = IllegalArgumentException.class)
    public void testInvalidOperator() {
        new Arithmetic(2, 3, '*'); // 非法运算符应抛异常
    }
}
